Skip to content

feat: v0.6.0 - source_path param, stress_test error detail, docs#2

Merged
SummerOneTwo merged 2 commits intomasterfrom
feat/v0.6.0-improvements
Apr 25, 2026
Merged

feat: v0.6.0 - source_path param, stress_test error detail, docs#2
SummerOneTwo merged 2 commits intomasterfrom
feat/v0.6.0-improvements

Conversation

@SummerOneTwo
Copy link
Copy Markdown
Owner

Summary

  • source_path 参数: 所有构建工具新增 source_path 参数,可直接指定源文件路径,无需传入完整源码字符串。支持编码回退(UTF-8 → latin-1)和相对 include 路径。
  • stress_test_run 错误增强: Generator 失败时包含 seed、cmd_args、stdout、stderr、last_input;区分超时/空输出/崩溃三种失败模式。
  • 文档完善: generator_args 协议说明、n_max 参数关系、题目目录结构文档。
  • 版本升级: 0.5.0 → 0.6.0

Changes

Issue Description
#1 stress_test_run 错误信息不够详细
#2 stress_test_run "Generator failed" 实际上是成功
#3 solution_build 的 code 参数需要完整源码
#4 generator_build 同样需要完整源码
#5 generator_args 缺少自定义参数的文档
#6 文件同步问题:solution/ vs solutions/ 目录
#7 stress_test_run 的 n_max 参数与 generator 的 n_max 语义不同

Test plan

  • uv run pytest tests/ -q — 176 passed
  • uvx ruff check . — All checks passed
  • Codex review — 2 P2 issues found and fixed (encoding fallback, include dirs)

Copilot AI review requested due to automatic review settings April 25, 2026 08:22
- Add source_path parameter to all build tools (solution_build,
  generator_build, validator_build, checker_build, interactor_build)
  as alternative to passing full source code via code parameter
- Add encoding fallback (UTF-8 -> latin-1) for source_path files
- Add include_dirs support so relative includes work with source_path
- Enhance stress_test_run error messages with seed, cmd_args, stdout,
  stderr, last_input for easier debugging
- Distinguish generator failure modes (timeout/empty output/crash)
  with mode-specific hints
- Document generator_args protocol and n_max parameter relationship
- Add effective_n_max to stress_test_run success result
- Add problem directory structure docs to CLAUDE.md
- Bump version to 0.6.0
@SummerOneTwo SummerOneTwo force-pushed the feat/v0.6.0-improvements branch from 6b531ce to d48c121 Compare April 25, 2026 08:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR releases v0.6.0 by adding source_path support across build tools, improving stress_test_run generator failure diagnostics, and updating documentation/versioning.

Changes:

  • Add source_path (optional) to build tools, with encoding fallback and include-dir support for relative #include.
  • Enhance stress_test_run generator failure reporting (seed/cmd_args/stdout/stderr/last_input) and expose effective_n_max on success.
  • Update docs (generator_args protocol, n_max semantics, problem directory layout) and bump version to 0.6.0.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
uv.lock Updates locked editable package version entry.
src/autocode_mcp/tools/validator.py Adds source_path input and include-dir support for validator build.
src/autocode_mcp/tools/stress_test.py Improves generator error classification/details; returns effective_n_max.
src/autocode_mcp/tools/solution.py Adds source_path input and include-dir support for solution builds.
src/autocode_mcp/tools/mixins.py Extends build mixin to forward include_dirs into compilation.
src/autocode_mcp/tools/interactor.py Adds source_path input and include-dir support for interactor build.
src/autocode_mcp/tools/generator.py Adds source_path input and include-dir support for generator build.
src/autocode_mcp/tools/checker.py Adds source_path input and include-dir support for checker build.
pyproject.toml Bumps project version to 0.6.0.
CLAUDE.md Documents problem directory structure and adds problem_validate in tool list.
CHANGELOG.md Adds 0.6.0 release notes describing new features/improvements.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CHANGELOG.md Outdated
### Features

- **source_path 参数**: 所有构建工具(solution_build, generator_build, validator_build, checker_build, interactor_build)新增 `source_path` 参数,可直接指定源文件路径,无需传入完整源码字符串。`code` 参数不再为必填,与 `source_path` 二选一。
- **source_path 编码回退**: 自动处理非 UTF-8 编码的源文件(如 GBK),先尝试 UTF-8 读取,失败后回退到 latin-1。
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里举例写“如 GBK”,但实现仅做 UTF-8 读取失败后回退 latin-1;latin-1 并不能正确解码 GBK(只是不会抛解码异常),可能导致源码内容乱码。建议要么实现真正的 GBK/自动检测(如优先尝试 gbk/cp936,或引入 charset 检测),要么把文档表述改为“回退到 latin-1(宽松解码)”而不暗示支持 GBK。

Suggested change
- **source_path 编码回退**: 自动处理非 UTF-8 编码的源文件(如 GBK),先尝试 UTF-8 读取,失败后回退到 latin-1。
- **source_path 编码回退**: 自动处理非 UTF-8 编码的源文件,先尝试 UTF-8 读取,失败后回退到 latin-1(宽松解码)

Copilot uses AI. Check for mistakes.
},
},
"required": ["problem_dir", "solution_type", "code"],
"required": ["problem_dir", "solution_type"],
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当前 input_schema 只要求 problem_dir,但 execute() 实际要求必须提供 code 或 source_path(二选一)。这会让 MCP client 依据 schema 生成/校验参数时遗漏必填字段。建议在 schema 增加 anyOf/oneOf 来约束至少提供一个(例如 anyOf: [{required:["code"]},{required:["source_path"]}]),同时保留 source_path 优先级逻辑。

Suggested change
"required": ["problem_dir", "solution_type"],
"required": ["problem_dir", "solution_type"],
"anyOf": [
{"required": ["code"]},
{"required": ["source_path"]},
],

Copilot uses AI. Check for mistakes.
},
},
"required": ["problem_dir", "code"],
"required": ["problem_dir"],
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当前 input_schema 只要求 problem_dir,但 execute() 实际要求必须提供 code 或 source_path(二选一)。这会导致 client 依据 schema 生成/校验参数时可能遗漏必填字段。建议在 schema 增加 anyOf/oneOf 来约束至少提供一个(例如 anyOf: [{required:["code"]},{required:["source_path"]}])。

Suggested change
"required": ["problem_dir"],
"required": ["problem_dir"],
"anyOf": [
{"required": ["code"]},
{"required": ["source_path"]},
],

Copilot uses AI. Check for mistakes.
Comment thread src/autocode_mcp/tools/stress_test.py Outdated
Comment on lines +182 to +184
with open(input_path) as f:
input_data = f.read()
last_input = input_data
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里读取 input.txt 时未指定 encoding,依赖系统默认编码;但 _generate_input 写入时固定使用 UTF-8。非 UTF-8 默认环境下可能出现解码异常或读到错误内容。建议读取时也显式指定 encoding="utf-8"(与写入保持一致)。

Copilot uses AI. Check for mistakes.
Comment on lines +76 to +92
# 解析源代码:source_path 优先于 code
source_dir = None
if source_path:
if not os.path.isabs(source_path):
source_path = os.path.join(problem_dir, source_path)
if not os.path.exists(source_path):
return ToolResult.fail(f"Source file not found: {source_path}")
try:
with open(source_path, encoding="utf-8") as f:
code = f.read()
except UnicodeDecodeError:
try:
with open(source_path, encoding="latin-1") as f:
code = f.read()
except Exception as e:
return ToolResult.fail(f"Failed to read source file: {e}")
source_dir = os.path.dirname(os.path.abspath(source_path))
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新增的 source_path 参数(含相对路径解析 + include_dirs 注入 + 编码回退)目前在 tests/test_tools 下没有覆盖:现有工具测试都只通过 code 字符串调用 build。建议补充至少一个用例:将源码写到临时文件后通过 source_path 调用,并验证包含相对 #include 的场景能成功编译。

Copilot uses AI. Check for mistakes.
stderr=gen_result.get("stderr", ""),
stdout=gen_result.get("stdout", ""),
cmd_args=gen_result.get("cmd_args", []),
last_input=last_input,
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里增强了 generator 失败时返回的诊断字段(seed/cmd_args/stdout/stderr/last_input)以及成功时的 effective_n_max,但 tests/test_tools/test_stress_test.py 目前只覆盖“通过/缺少生成器”等路径,没有断言这些新增字段是否按预期返回。建议补充一个让 generator 超时/空输出/崩溃的用例,验证错误类型提示与 data 字段完整性。

Suggested change
last_input=last_input,
last_input=gen_result.get("last_input", last_input),

Copilot uses AI. Check for mistakes.
},
},
"required": ["problem_dir", "code"],
"required": ["problem_dir"],
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当前 input_schema 只要求 problem_dir,但 execute() 实际要求必须提供 code 或 source_path(二选一)。建议在 schema 增加 anyOf/oneOf 来约束至少提供一个,避免 client 按 schema 调用时得到运行期报错。

Suggested change
"required": ["problem_dir"],
"required": ["problem_dir"],
"anyOf": [
{"required": ["code"]},
{"required": ["source_path"]},
],

Copilot uses AI. Check for mistakes.
},
},
"required": ["problem_dir", "code"],
"required": ["problem_dir"],
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当前 input_schema 只要求 problem_dir,但 execute() 实际要求必须提供 code 或 source_path(二选一)。建议在 schema 增加 anyOf/oneOf 来约束至少提供一个,避免 client 按 schema 调用时参数不完整。

Suggested change
"required": ["problem_dir"],
"required": ["problem_dir"],
"anyOf": [
{"required": ["code"]},
{"required": ["source_path"]},
],

Copilot uses AI. Check for mistakes.
},
},
"required": ["problem_dir", "code"],
"required": ["problem_dir"],
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当前 input_schema 只要求 problem_dir,但 execute() 实际要求必须提供 code 或 source_path(二选一)。建议在 schema 增加 anyOf/oneOf 来约束至少提供一个,避免 client 依据 schema 调用时遗漏参数。

Suggested change
"required": ["problem_dir"],
"required": ["problem_dir"],
"anyOf": [
{"required": ["code"]},
{"required": ["source_path"]},
],

Copilot uses AI. Check for mistakes.
- Add anyOf to 5 build tool schemas enforcing code/source_path requirement
- Fix CHANGELOG: remove misleading GBK example for latin-1 fallback
- Add encoding="utf-8" to stress_test.py file reads
- Add tests for source_path (success, not found, neither provided)
- Add test for stress_test generator failure diagnostics
@SummerOneTwo SummerOneTwo merged commit 8d23598 into master Apr 25, 2026
6 checks passed
@SummerOneTwo SummerOneTwo deleted the feat/v0.6.0-improvements branch April 25, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants